local skel = fk.CreateSkill{--定义
  name = "kpaI__tongfeng",
}

Fk:loadTranslationTable{--翻译
  ["kpaI__tongfeng"] = "彤锋",
  [":kpaI__tongfeng"] = "每回合首次有牌因使用进入弃牌堆后，你可以弃置一张牌，获得其中的伤害牌。",
  ["#kpaI__tongfenginfo"] = "彤锋：你可弃置一张牌，获得被使用牌中的伤害牌",

  ["$kpaI__tongfeng1"] = "有草生清池，无根碧波上。",
  ["$kpaI__tongfeng2"] = "愿为浮萍草，托身寄清池。",
}

skel:addEffect(fk.AfterCardsMove,{
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and not (player:getMark("@@kpaI__tongfeng-turn") > 0) then
      local ids = {}
      for _, move in ipairs(data) do
        if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonUse then
          player:setMark("@@kpaI__tongfeng-turn",1)
          for _, info in ipairs(move.moveInfo) do
            if Fk:getCardById(info.cardId).is_damage_card then
              table.insertIfNeed(ids, info.cardId)
            end
          end
        end
      end
      ids = table.filter(ids, function (id)
        return table.contains(player.room.discard_pile, id)
      end)
      ids = player.room.logic:moveCardsHoldingAreaCheck(ids)
      if #ids > 0 then
        event:setCostData(self, {ids = ids})
        return true
      end
    end
  end,
  on_cost =function (self, event, target, player, data)
    local icards = event:getCostData(self).ids
    player.room:showCards(icards)
    local to, card = player.room:askToChooseCardsAndPlayers(player, {
      min_card_num = 1,
      max_card_num = 1,
      min_num = 0,
      max_num = 0,
      targets = {},
      skill_name = skel.name,
      prompt = "#kpaI__tongfenginfo:",
      cancelable = true,
      will_throw = true,
    })
    if #card > 0 then
      event:setCostData(self, {choose = card[1]})
      return true
    end
  end,
  on_use =function (self, event, target, player, data)
    local room = player.room
    local ids = {}
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile and move.moveReason == fk.ReasonUse then
        for _, info in ipairs(move.moveInfo) do
          if Fk:getCardById(info.cardId).is_damage_card then
            table.insertIfNeed(ids, info.cardId)
          end
        end
      end
    end
    ids = table.filter(ids, function (id)
      return table.contains(player.room.discard_pile, id)
    end)
    ids = player.room.logic:moveCardsHoldingAreaCheck(ids)
    room:throwCard(event:getCostData(self).choose, skel.name, player, player)
    room:moveCardTo(ids,Card.PlayerHand, player,fk.ReasonJustMove,skel.name,nil,true,player)
  end,
})

return skel